$(function(){
    function environmentArgument() {
        setInterval(environmentArgument,1000);
        $.ajax({
            url:"environmentlogShow",
            success:function (data) {
                // console.log(data)
                $("#methVal").html(data.methane+"ppm");
                $("#methValImg").attr("src","img/potency2.png")
                $("#oxyVal").html(data.o2+"ppm");
                $("#oxyValImg").attr("src","img/potency2.png")

                $("#humVal").html(data.wet+"%");
                if(data.wet<40){
                    $("#humValImg").attr("src","img/Temperature/Temperature1.png");
                }else if(data.wet<60){
                    $("#humValImg").attr("src","img/Temperature/Temperature2.png");
                }else if(data.wet<80){
                    $("#humValImg").attr("src","img/Temperature/Temperature3.png");
                }else if(data.wet<100){
                    $("#humValImg").attr("src","img/Temperature/Temperature4.png");
                }else if(data.wet=100){
                    $("#humValImg").attr("src","img/Temperature/Temperature5.png");
                }

                var domWind = document.getElementById("container8");
                var myChartWind = echarts.init(domWind);
                var app = {};

                var optionWind;



                optionWind = {
                    title: {
                        left: "center",
                        verticalAlign:"bottom",
                        textStyle: {
                            fontSize: 13,
                            lineHeight: 5,
                            color:"white",
                            align: "right",
                            verticalAlign: "bottom"
                        },
                        show: true,
                        text: "当前风速"
                    },
                    series: [{
                        center: [35,50],
                        type: 'gauge',
                        axisLine: {
                            lineStyle: {
                                width: 4,
                                color: [
                                    [0.3, '#67e0e3'],
                                    [0.7, '#37a2da'],
                                    [1, '#fd666d']
                                ]
                            }
                        },
                        pointer: {
                            itemStyle: {
                                color: 'auto'
                            }
                        },
                        axisTick: {
                            distance: -30,
                            length: 8,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        splitLine: {
                            distance: -30,
                            length: 30,
                            lineStyle: {
                                color: '#fff',
                                width: 0
                            }
                        },
                        axisLabel: {
                            color: 'auto',
                            distance: 0,
                            fontSize: 0
                        },
                        detail: {
                            valueAnimation: true,
                            formatter:'{value}km/s',
                            color: 'white',
                            fontSize: 13,
                            offsetCenter: [0,"100%"],
                        },
                        data: [{
                            value: data.windSpd,
                        }]
                    }]
                };

                // setInterval(function () {
                //     option.series[0].data[0].value = (Math.random() * 100).toFixed(2) - 0;
                //     myChart.setOption(option, true);
                // }, 2000);

                // if (option && typeof option === 'object') {
                myChartWind.setOption(optionWind);
                // }
            }
        });
    }
    environmentArgument();
})

